#include"MyString.h"
#include<iostream>
using std::cout;
using std::cin;
using std::endl;
using namespace MyS;
void text()
{

  MyS::string s;

  MyS::string s1("hell");
  MyS::string s2(s1);
  s2.push_back('o');
  s2.insert(0,"_world");
  auto it = s1.begin();
  for(;it != s1.end();it++)
  {
    cout << (*it);
  }
  cout << endl;
  it = s2.begin();
  for(;it != s2.end();it++)
  {
    cout << (*it);
  }
  cout << endl;
}
void text2()
{
  MyS::string s;
  s.push_back('a');
}
void text3()
{
  string s;
  s.reserve(10);
  size_t tmp = s.capacity();
  for(int i = 0;i<20;i++)
  {
    s.push_back(i+'0');
    if(s.capacity() != tmp){
      tmp = s.capacity();
    cout << s.capacity() << endl;
    }
  }

  for(int i = 0;i<20;i++)
  {
    cout << s.at(i) << " ";
  }
  cout << endl;

}
void text4()
{
  string s;
  s.resize(20,'a');
  for(auto it = s.begin();it != s.end();it++)
  {
    cout << (*it) << " ";
  }
  cout << endl;
  s.resize(5);
  for(auto it = s.begin();it != s.end();it++)
  {
    cout << (*it) << " ";
  }
  cout << endl;
  string s2;
  s2.append("hello ");
  cout << s2.c_str() << endl;
  s2 += s;
  cout << s2.c_str() << endl;
  for(auto it = s2.begin();it != s2.end();it++)
  {
    cout << (*it) << " ";
  }
  cout << endl;
  s2.push_pop();
  s2.push_pop();
  s2.push_pop();
  for(auto it = s2.begin();it != s2.end();it++)
  {
    cout << (*it) << " ";
  }
  cout << endl;
  s2.insert(2,"insert");
  for(auto it = s2.begin();it != s2.end();it++)
  {
    cout << (*it) << " ";
  }
  cout << endl;
}
void text5()
{
  string s("hzllo worad");
  string s1("hello world");
  if(s == s1)
  {
    cout << "it is ==" << endl;
  }
  if(s > s1)
  {
    cout << "it is big" << endl;
  }
  if(s < s1)
  {
    cout << "it is xiao" << endl;
  }

  cout << s1 << endl;
  char ch = s1[0];
  cout << ch << endl;
  cin >> s;
  cout << s << endl;

}
void text6()
{
  string s("hello,i am lhb");
  string s1("am");
  const char* s2 = "am";
  size_t i = s.find(s1);
  cout << s[i] << endl;
  
  s.find(s2);
  size_t j = s.find(s2);
  cout << s[j] << endl;


}
int main()
{
  text6();
 // text5();
//    text4();
//     text2();
//  text();
  return 0;
}
